#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from utilsMod import *

#Default values 4 key

daysKeyAvailable = 30 # время действия ключа

class Key:

    def __init__(self):
        self._key = {}

    def FromDb(self, db):
        self._key = db
        return self

    def FromCb(self, cb):

        self._key = {
            'ClientTGid': int(cb.message.from_user.id)
          , 'ClientOutlineName': ''
          , 'ClientOutlineKey': ''
          , 'ClientTGname': cb.message.from_user.first_name #+ ' ' + cb.message.from_user.last_name -- TODO: maybe none
          , 'ClientTGaccount': ''
          , 'ClientTarif': 'basic'
          , 'Payment_method': 'cash'
          , 'PaydTill': timeNowPlusDelta(days=daysKeyAvailable)
          , 'PaymentPeriod': daysKeyAvailable
          , 'IsActive': 0
          , 'RegistrationDate': timeNowGMT()
        }
        return self

    def Get(self):
        return self._key

    @property
    def text(self):
        return f"{self._key['ClientTGname']}:{self._key['ClientTGid']}"

    @property
    def id(self):
        return self._key['id']

    def ShowKeyPretty(self):

        outText = f"TelegramID: {self._key['ClientTGid']} \n"
        outText += f"Имя: {self._key['ClientTGname']} \n"
        #outText += f"Действует до: {toHumanReadable(self._key['PaydTill'])} \n"
        #outText += f"Оплаченный период: {self._key['PaymentPeriod']} \n"

        return outText
